-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: add Module.print_hierarchy #281
base: master
Are you sure you want to change the base?
Conversation
migen/fhdl/module.py
Outdated
continue | ||
name = "anon" | ||
print("{}{}:{}".format(" " * indent, name, submodule.__class__.__name__)) | ||
self._iter_submodules(submodule, indent=indent+4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just call print_hierarchy instead and merge the two functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed _iter_submodules.
64f1182
to
f5b678e
Compare
There do seem to be some nice options for pretty printing this but I'll leave that for another day. This simple indentation works for now I think. https://stackoverflow.com/questions/9727673/list-directory-tree-structure-in-python |
migen/fhdl/module.py
Outdated
continue | ||
name = "anon" | ||
print("{}{}:{}".format(" " * indent, name, submodule.__class__.__name__)) | ||
self.print_hierarchy(submodule, indent+4, include_anon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just submodule.print_hierarchy and remove the module argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I see what you're getting at.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a fix that I think did what you wanted. Each submodule is called in turn and we call the submodule.print_hierarchy(indent+4, include_anon)
.
Adding a new Module method that prints the hierarchy. Useful for visualising the structure of a module.
f5b678e
to
1303e93
Compare
@sbourdeauducq Did the last push do what you were implying? |
It's better, there is still an issue with indent handling, just do the *4 multiplication at print time. |
Not sure what you mean. The multiplication is done at print time. Did you mean something else? if indent == 4:
print(self.__class__.__name__)
for name, submodule in self._submodules:
if name is None:
if not include_anon:
# all hierarchy below an anonymous module is skipped
continue
name = "anon"
print("{}{}:{}".format(" " * indent, name, submodule.__class__.__name__))
submodule.print_hierarchy(indent+4, include_anon) |
The 4 |
++verbosity |
Adding a new Module method that prints the hierarchy. Useful for visualising the structure of a module.
I'm adding this PR mainly to start a conversation about where is best to do this sort of thing. I'd like to be able to pretty print some sort of hierarchy view of a design. It would be nice to be able to do something similar to how
tree
prints directory hierarchies but I haven't looked further that the simple indentation shown in this PR.Should this go in the
Module
class or in theverilog
module or in some new module?